package com.gt.controller.admin;

import com.gt.pojo.PageResult;
import com.gt.pojo.Result;
import com.gt.pojo.dto.BorrowConfirmDTO;
import com.gt.pojo.dto.BorrowPageQueryDTO;
import com.gt.service.BorrowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController(value = "adminBorrowController")
@Api(tags = "借阅管理")
@RequestMapping("admin/borrow")
public class BorrowController {
    @Autowired
    private BorrowService borrowService;


    @GetMapping("/conditionSearch")
    @ApiOperation("借阅查询")
    public Result<PageResult> conditionSearch(BorrowPageQueryDTO borrowPageQueryDTO){
        PageResult pageResult = borrowService.conditionSearch(borrowPageQueryDTO);
        return Result.success(pageResult);
    }

    @PutMapping("/confirm")
    @ApiOperation("审核通过")
    public Result confirm(@RequestBody BorrowConfirmDTO borrowConfirmDTO){
        borrowService.confirm(borrowConfirmDTO);
        return Result.success();
    }
    @DeleteMapping
    @ApiOperation("删除归还书籍")
    public Result delete(Long id){
        borrowService.deleteById(id);
        return Result.success();
    }
}
